<?php
    include 'base.php';

    $ID = $_POST['ID'];
    $reusername = $_POST['username'];
    $repassword = $_POST['password'];


    $sql = "SELECT * FROM `newuser` WHERE `ID`='$ID'";
    $res = $conn -> query($sql);
    $row = mysqli_fetch_assoc($res);

    if($row) {
        echo json_encode (Array("err" => 0,"msg" => "帐号已注册 请登录!","code" => 200));
    } else {
        $insql = "INSERT INTO `newuser` VALUES('$ID','$reusername','$repassword')";
        $inres = $conn -> query($insql);

        echo json_encode(Array("err" => 1,"msg" => "注册成功，请登录!","code" => 200));
    }
?>